/**
* 头部菜单
*/ 
<template>
  <el-menu
    class="el-menu-demo"
    mode="horizontal"
    background-color="#2A3139"
    text-color="#fff"
    active-text-color="#fff"
  >
    <div
      style="
        height: 60px;
        display: flex;
        justify-content: flex-start;
        align-items: center;
      "
    >
      <div
        style="
          display: flex;
          justify-content: flex-start;
          align-items: center;
          margin-left: 30px;
        "
      >
        <div class="top-nav-img">
          <img style="width: 20px; height: 20px" :src="imgsq" />
        </div>
        <span style="color: #888; font-size: 14px">首页</span>
      </div>
      <div
        style="
          display: flex;
          justify-content: flex-start;
          align-items: center;
          margin-left: 30px;
        "
      >
        <div class="top-nav-img">
          <img style="width: 20px; height: 20px" :src="imgsq" />
        </div>
        <span style="color: #888; font-size: 14px">主数据</span>
      </div>
      <div
        style="
          display: flex;
          justify-content: flex-start;
          align-items: center;
          margin-left: 30px;
        "
      >
        <div class="top-nav-img">
          <img style="width: 20px; height: 20px" :src="imgsq" />
        </div>
        <span style="color: #888; font-size: 14px">辖区管理</span>
      </div>
      <div
        style="
          display: flex;
          justify-content: flex-start;
          align-items: center;
          margin-left: 30px;
        "
      >
        <img style="width: 100px; height: 40px" src="../assets/img/xxt.png" />
      </div>
    </div>
  </el-menu>
</template>
<script>
export default {
  name: "navcon",
  data() {
    return {
      collapsed: true,
      imgshow: require("../assets/img/show.png"),
      imgsq: require("../assets/img/sq.png"),
      user: {},
    };
  },
  // 创建完毕状态(里面是操作)
  created() {
    this.user = JSON.parse(localStorage.getItem("userdata"));
  },
  methods: {
    // 退出登录
    exit() {
      this.$confirm("退出登录, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          setTimeout(() => {
            this.$store.commit("logout", "false");
            this.$router.push({ path: "/login" });
            this.$message({
              type: "success",
              message: "已退出登录!",
            });
          }, 1000);
          // loginout()
          //   .then(res => {
          //     if (res.success) {
          //       //如果请求成功就让他2秒跳转路由
          //       setTimeout(() => {
          //         this.$store.commit('logout', 'false')
          //         this.$router.push({ path: '/login' })
          //         this.$message({
          //           type: 'success',
          //           message: '已退出登录!'
          //         })
          //       }, 1000)
          //     } else {
          //       this.$message.error(res.msg)
          //       this.logining = false
          //       return false
          //     }
          //   })
          //   .catch(err => {
          //     // 获取图形验证码
          //     this.getcode()
          //     this.logining = false
          //     this.$message.error('退出失败，请稍后再试！')
          //   })
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消",
          });
        });
    },
    // 切换显示
    toggle(showtype) {
      this.collapsed = !showtype;
      this.$root.Bus.$emit("toggle", this.collapsed);
    },
  },
};
</script>
<style scoped>
.top-nav-img {
  padding: 2px 4px;
  background-color: #ffffff42;
  border-radius: 6px;
  margin-right: 4px;
}
.el-menu-vertical-demo:not(.el-menu--collapse) {
  border: none;
}
.submenu {
  float: right;
}
.buttonimg {
  height: 60px;
  background-color: transparent;
  border: none;
}
.showimg {
  width: 26px;
  height: 26px;
  position: absolute;
  top: 17px;
  left: 17px;
}
.showimg:active {
  border: none;
}
</style>